package com.yl.framework.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.yl.common.utils.SecurityUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MymetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        /***填充创建时间**/
        metaObject.setValue("createTime", new Date());
        /***填充创建人**/
        metaObject.setValue("createBy", SecurityUtils.getUsername());
        /***填充修改时间**/
        metaObject.setValue("updateTime", new Date());
        /***填充修改人**/
        metaObject.setValue("updateBy", SecurityUtils.getUsername());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        /***填充修改时间**/
        metaObject.setValue("updateTime", new Date());
        /***填充修改人**/
        metaObject.setValue("updateBy", SecurityUtils.getUsername());
    }
}
